package org.smart4j.plugin.security;

import java.util.Set;

import javax.servlet.FilterRegistration;
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.shiro.web.env.EnvironmentLoaderListener;

/**
 * description: Smart Security 插件
 * @version v1.0
 * @author w
 * @date 2018年11月4日下午2:53:26
 **/
public class SmartSecurityPlugin implements ServletContainerInitializer{

	@Override
	public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
		// 设置初始化参数
		servletContext.setInitParameter("shiroConfigLocations", "classpath:smart-security.ini");
		// 注册 Listener
		servletContext.addListener(EnvironmentLoaderListener.class);
		// 注册 Filter
		FilterRegistration.Dynamic smartSecurityFilter = servletContext.addFilter("SmartSecurityFilter", SmartSecurityFilter.class);
		smartSecurityFilter.addMappingForUrlPatterns(null, false, "/*");
	}
	
	
	
}
